package mathgame.core;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;

public class TimeAttackTimer extends Observable {

    private javax.swing.Timer timer;
    private int repeated;
    private int iterations;
    //private Controller controller;

    public TimeAttackTimer(){
       // controller = ControlFactory.getController();
        iterations = 60;
        timer = new javax.swing.Timer(1000, new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                repeated++;
                setChanged();
                notifyObservers(repeated);
                if(repeated==iterations){
                    timer.stop();
                }
            }
        });
        timer.setRepeats(true);
    }

    public void stopTimer(){
        timer.stop();
    }

    public void startTimer(){
        timer.start();
    }

    public int getiterations(){
        return iterations;
    }
}
